# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=gnupg
pkgver=2.2.27
pkgrel=1
pkgdesc='Complete and free implementation of the OpenPGP standard'
provides=('dirmngr' "gnupg2=${pkgver}")
url='https://gnupg.org/'
license=('GPL')
arch=('i686' 'x86_64')
makedepends=('gettext-devel'
             'libassuan-devel'
             'libbz2-devel'
             'libcurl-devel'
             'libgcrypt-devel'
             'libgnutls-devel'
             'libgpg-error-devel'
             'libiconv-devel'
             'libksba-devel'
             'libnettle-devel'
             'libnpth-devel'
             'libp11-kit-devel'
             'libreadline-devel'
             'libsqlite-devel'
             'libtasn1-devel'
             'libunistring-devel'
             'nettle'
             'tar'
             'zlib-devel')
optdepends=('curl: gpg2keys_curl')
depends=('bzip2'
         'libassuan'
         'libbz2'
         'libcurl'
         'libgcrypt'
         'libgpg-error'
         'libgnutls'
         'libiconv'
         'libintl'
         'libksba'
         'libnpth'
         'libreadline'
         'libsqlite'
         'nettle'
         'pinentry'
         'zlib'
        )
source=("https://gnupg.org/ftp/gcrypt/${pkgname}/${pkgname}-${pkgver}.tar.bz2"{,.sig}
        'gnupg-2.2.8-msys2.patch')
sha256sums=('34e60009014ea16402069136e0a5f63d9b65f90096244975db5cea74b3d02399'
            'SKIP'
            'cb23f1a61fd213c25e85b6ba8afb190b7da14a8cfa59cc56ce82df941db8c3c9')
validpgpkeys=('D8692123C4065DEA5E0F3AB5249B39D24F25E3B6'
              '46CC730865BB5C78EBABADCF04376F3EE0856959'
              '031EC2536E580D8EA286A9F22071B08A33BD3F06'
              '5B80C5754298F0CB55D8ED6ABCEF7E294B092E28'
              '6DAA6E64A76D2840571B4902528897B826403ADA')
install=${pkgname}.install

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  sed '/noinst_SCRIPTS = gpg-zip/c sbin_SCRIPTS += gpg-zip' -i tools/Makefile.in
  patch -p1 -i ${srcdir}/gnupg-2.2.8-msys2.patch

  ./autogen.sh --force

  sed 's/development_version=yes/development_version=no/' -i configure
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
    --build=${CHOST} \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib/gnupg \
    --disable-libdns \
    --enable-maintainer-mode

  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
}
